﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Domain;
using Domain.Entities;
using BusinessLogic.Interfaces;


namespace BusinessLogic.Implementations
{
    public class EFDepartmentsRepository : IDepartmentsRepository
    {
        private DomainContext context;
        public EFDepartmentsRepository(DomainContext context)
        {
            this.context = context;
        }

        public IEnumerable<Department> GetDepartments()
        {
            return context.Departments;
        }
        
        public Department GetDepartmentById(int id)
        {
            return context.Departments.FirstOrDefault(x => x.ID == id);
        }

        public Department GetDepartentByName(string name)
        {
            return context.Departments.FirstOrDefault(x => x.Name == name);
        }
        
    }
}
